<template>
  <div class="head">
    <div class="head_left">
      tokentask
    </div>
    <div class="head_right">
      <span>hi，{{username}}</span><span>,拥有token数：{{ currentTokenCount }}</span>
    </div>
  </div>
</template>

<script>
import { getStore } from '@/controller/utils'
import { getTokenCount } from '@/controller/api'
export default {
  data() {
    return {
      username: '',
      currentTokenCount: 0
    }
  },
  created(){
    this.username = getStore('username');
    this.getTokenData();
  },
  methods: {
    getTokenData() {
      getTokenCount({username: this.username}).then(
        res => {
          this.currentTokenCount = res.data.data.amount
        }
      );
    }
  }
}
</script>

<style lang="less" scoped>
  .head{
    position: fixed;
    width: 100%;
    left: 0;
    top: 0;
    right: 0;
    height: 0.8rem;
    background: #262729;
    overflow: hidden;
    padding-left: 0.3rem;
    padding-right: 0.4rem;
    z-index: 99;
    .head_left{
      float: left;
      font-size: 0.2rem;
      color: #FFFFFF;
      line-height: 0.8rem;
    }
    .head_right{
      float: right;
      font-size: 0.14rem;
      color: #FFFFFF;
      line-height: 0.8rem;
    }
  }
</style>